﻿using UnityEngine.Events;
using UnityEngine.UI;

namespace WzhModule.GM
{
    public class WzhGMSlider : Slider
    {

        public string SliderInfo = "";
        public float Value;
        private int Id = -1;
        private UnityAction<int, float> Action = null;

        public void AddAction(UnityAction<int, float> action, int id, string info)
        {
            Id = id;
            Action = action;
            SliderInfo = info;
            onValueChanged.AddListener(ValueChanged);
        }

        private void ValueChanged(float value)
        {
            Value = value;
            Action.Invoke(Id, value);
        }

        public void Clear()
        {
            Id = -1;
            Action = null;
            SliderInfo = "";
            onValueChanged.RemoveAllListeners();
        }



    }
}
